/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package test_sip;
import com.sun.xml.internal.messaging.saaj.soap.ver1_1.Header1_1Impl;
import java.text.ParseException;
import java.util.TooManyListenersException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sip.*;
import javax.sip.address.URI;
import javax.sip.message.Request;
import java.util.Properties;
import javax.sip.address.Address;
import javax.sip.address.AddressFactory;
import javax.sip.address.SipURI;
import javax.sip.header.FromHeader;
import javax.sip.header.HeaderFactory;
import javax.sip.message.MessageFactory;
/**
 *
 * @author steven
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public SipFactory sipFactory;
    public SipStack sipStack_UAC;
    public HeaderFactory headerFactory;
    public MessageFactory messageFactory;
    public AddressFactory addressFactory;
    public ListeningPoint listenPoint;
    public SipProvider sipProvider;
    public SipListener sipListener;
    public SipURI requestURI;
    public SipURI fromAddress;
    public Address fromNameAddress;
    public FromHeader fromHeader;
    public SipURI toAddress;
public void init() throws PeerUnavailableException, InvalidArgumentException, ObjectInUseException, TooManyListenersException{
    Properties properity=new Properties();
    properity.setProperty("local", "127.0.0.1");
    sipFactory=SipFactory.getInstance();
     sipStack_UAC=sipFactory.createSipStack(properity);
//    SipStack sipStack_UAS=sipFactory.createSipStack(properity);
    headerFactory= sipFactory.createHeaderFactory();
    addressFactory = sipFactory.createAddressFactory();
        try {
            listenPoint = sipStack_UAC.createListeningPoint("127.0.0.1", 5070, "udp");
        } catch (TransportNotSupportedException ex) {
            ex.printStackTrace();
           System.out.println("Transport Not Support!!!");
        }
    sipProvider = sipStack_UAC.createSipProvider(listenPoint);
    sipListener= new Implement_Listener();
    sipProvider.addSipListener(sipListener);
}
public void createrequest() throws ParseException{
 requestURI=addressFactory.createSipURI("steven","5001");
 fromAddress=addressFactory.createSipURI("Tian",
"5002");
fromNameAddress=addressFactory.createAddress(fromAddress);
fromNameAddress.setDisplayName("Friend");
fromHeader=headerFactory.createFromHeader(fromNameAddress,"10");
toAddress=addressFactory.createSipURI("Jerry", "5002");

}
    public static void main(String[] args) {
        // TODO code application logic here

    }

}
